use std::fmt;

/// 智能体操作错误类型
#[derive(Debug)]
pub enum AgentError {
    /// 无效操作
    InvalidAction(String),
    /// 资源不足
    InsufficientResources,
    /// 状态冲突
    StateConflict,
    /// 内部错误
    InternalError(String),
}

impl fmt::Display for AgentError {
    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
        match self {
            AgentError::InvalidAction(msg) => write!(f, "无效操作: {}", msg),
            AgentError::InsufficientResources => write!(f, "资源不足"),
            AgentError::StateConflict => write!(f, "状态冲突"),
            AgentError::InternalError(msg) => write!(f, "内部错误: {}", msg),
        }
    }
}

impl std::error::Error for AgentError {}

/// 智能体操作结果类型
pub type AgentResult<T> = std::result::Result<T, AgentError>;